/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormularioListados.java
 *
 * Created on 19/02/2011, 04:00:18 PM
 */

package vistas;

import clases.Estudiante;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author
 */
public class FormularioListados extends javax.swing.JFrame {

    DefaultTableModel modelo;
    Vector<String> columnas;
    Vector<Estudiante> estudiantes;
    Vector filas;
    boolean notas;

    public void setEstudiantes(Vector<Estudiante> estudiantes) {
        this.estudiantes = estudiantes;
    }

    public void setNotas(boolean notas) {
        this.notas = notas;
    }




    /** Creates new form FormularioListados */
    public FormularioListados() {
        initComponents();
        modelo = new DefaultTableModel();
        jTable1.setModel(modelo);
    }

    public void listar(){
        columnas= new Vector<String>();
        columnas.add("Cedula");
        columnas.add("Nombre");
        columnas.add("Apellido");
        if(notas)
            columnas.add("Nota Final");
        modelo.setColumnIdentifiers(columnas);
        for (int i = 0; i < estudiantes.size(); i++) {
            filas= new Vector();
            filas.add(estudiantes.elementAt(i).getCedula());
            filas.add(estudiantes.elementAt(i).getNombre());
             filas.add(estudiantes.elementAt(i).getApellido());
             if(notas)
                 filas.add(estudiantes.elementAt(i).getNotafinal());
             modelo.addRow(filas);
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        btnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        jTable1.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(40, 50, 452, 227);

        btnSalir.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });
        getContentPane().add(btnSalir);
        btnSalir.setBounds(220, 290, 110, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-529)/2, (screenSize.height-353)/2, 529, 353);
    }// </editor-fold>//GEN-END:initComponents

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSalirActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FormularioListados().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSalir;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

}
